//
//  KTextView.m
//  newView
//
//  Created by yjl on 14-5-26.
//  Copyright (c) 2014年 上海傲融软件公司. All rights reserved.
//

#import "KTextField.h"

@implementation KTextField

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        
        
    }
    return self;
}

-(void)awakeFromNib
{
    
    [[NSBundle mainBundle] loadNibNamed:@"KTextField" owner:self options:nil];
    //允许圆角
    self.contentView.layer.masksToBounds = YES;
    //圆角角度
    self.contentView.layer.cornerRadius = 5.0;
    //边框色
    self.contentView.layer.borderColor = [UIColor colorWithRed:03.0f/255 green:169.0f/255 blue:206.0f/255 alpha:1].CGColor;
    //边框宽度
    self.contentView.layer.borderWidth = 2.0;
    
    self.txt.delegate = self;
    
    [self addSubview:self.contentView];

}

-(void)setStayle:(int)style
{
    switch (style) {
        case KTextStyle_User:
            
            [self.img setImage:[UIImage imageNamed:@"login_user.png"]];
            break;
        case KTextStyle_Pass:
            [self.img setImage:[UIImage imageNamed:@"login_pass.png"]];
            [self.txt setSecureTextEntry:YES];
    
            break;
        default:
            break;
    }
}


-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if ([string isEqualToString:@"\n"]) {
        [self.txt resignFirstResponder];
        return NO;
    }
    return YES;
}

@end
